// import com.alibaba.druid.sql.ast.SQLExpr;
// import com.alibaba.druid.sql.ast.SQLObject;
// import com.alibaba.druid.sql.ast.SQLObjectImpl;
// import com.alibaba.druid.sql.visitor.SQLASTVisitor;

// import java.util.ArrayList;
// import java.util.List;

#include "SQLAlterTableAddPartition.h"
#include "../../visitor/SQLASTVisitor.h"
#include "../SQLExpr.h"

SQLAlterTableAddPartition::SQLAlterTableAddPartition()
{
  partitions = std::make_shared<std::list<SQLObject_ptr>>();
}
SQLObject_list_ptr SQLAlterTableAddPartition::getPartitions()
{
  return partitions;
}

void SQLAlterTableAddPartition::addPartition(SQLObject_ptr x)
{
  if (x != nullptr)
  {
    x->setParent(SharedObject(SQLAlterTableAddPartition));
  }
  this->partitions->push_back(x);
}

BOOL_ptr SQLAlterTableAddPartition::isIfNotExists()
{
  return ifNotExists;
}

void SQLAlterTableAddPartition::setIfNotExists(BOOL_ptr ifNotExists)
{
  this->ifNotExists = ifNotExists;
}

SQLExpr_ptr SQLAlterTableAddPartition::getPartitionCount()
{
  return partitionCount;
}

void SQLAlterTableAddPartition::setPartitionCount(SQLExpr_ptr x)
{
  if (x != nullptr)
  {
    x->setParent(SharedObject(SQLAlterTableAddPartition));
  }
  this->partitionCount = x;
}

SQLExpr_ptr SQLAlterTableAddPartition::getLocation()
{
  return location;
}

void SQLAlterTableAddPartition::setLocation(SQLExpr_ptr x)
{
  if (x != nullptr)
  {
    x->setParent(SharedObject(SQLAlterTableAddPartition));
  }
  this->location = x;
}

// @Override
void SQLAlterTableAddPartition::accept0(SQLASTVisitor_ptr visitor)
{
  if (visitor->visit(SharedObject(SQLAlterTableAddPartition)))
  {
    acceptChild(visitor, partitions);
    acceptChild(visitor, partitionCount);
    acceptChild(visitor, location);
  }
  visitor->endVisit(SharedObject(SQLAlterTableAddPartition));
}
